package com.speljohan.rsbot.util;

import java.util.Random;

/**
 * Common functions
 */
public final class RandomUtils {
	/**
	 * Returns a random int
	 * 
	 * @param random
	 *            the generator to use
	 * @return a value between min and max, or between max and min if min is
	 *         larger than max.
	 */
	public static int randomInt(final Random random, final int min,
			final int max) {
		if (random == null) {
			throw new IllegalArgumentException("random cannot be null");
		}

		if (min == max) {
			return min;
		}

		if (min > max) {
			return RandomUtils.randomInt(random, max, min);
		}

		return min + random.nextInt(max - min);
	}

	private RandomUtils() { /* Should not be constructed */
	}
}
